package com.user.repositories;

import com.user.model.entity.Message;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface MessageRepository extends JpaRepository<Message,String>, JpaSpecificationExecutor {


    List<Message> findAllByUserIdAndDeletedOrderByReaded(String userId,char deleted);

    @Query(value = "select count(1) from t_message where 1=1 and user_id = ?1 and readed ='N' and deleted = 'N'",nativeQuery = true)
    int getCount(String userId);
}
